package com.finance.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.common.vo.PageVo;
import com.finance.dao.YhContactsMapper;
import com.finance.entity.YhContacts;

@Service("YhContactsService")
public class YhContactsService {
	
	@Resource(name = "YhContactsMapper")
	private YhContactsMapper yhContactsMapper;
	
	/**
	 * 按id删除
	 * @param contactsId
	 */
	public void deleteByPrimaryKey(String contactsId){
		yhContactsMapper.deleteByPrimaryKey(contactsId);
	}
	
	/**
	 * 添加联系人
	 * @param record
	 */
	public void insert(YhContacts record){
		yhContactsMapper.insert(record);
	}
	
	/**
	 * 按id查询
	 * @param contactsId
	 * @return
	 */
	public YhContacts selectByPrimaryKey(String contactsId){
		return yhContactsMapper.selectByPrimaryKey(contactsId);
	}
	
	/**
	 * 选择性更新
	 * @param record
	 */
	public void updateByPrimaryKeySelective(YhContacts record){
		yhContactsMapper.updateByPrimaryKeySelective(record);
	}
	
	/**
	 * 更新
	 * @param record
	 */
    public void updateByPrimaryKey(YhContacts record){
    	yhContactsMapper.updateByPrimaryKey(record);
    }
    
    /**
	 * 分页+搜索
	 * @param search
	 * @param pageNum
	 * @return
	 */
	public PageVo<YhContacts> findPageBySearch(YhContacts search,int pageNum){
		PageVo<YhContacts> page =new PageVo<YhContacts>(pageNum);
		page.setRows(3);
		List<YhContacts> list=yhContactsMapper.findByPageBySearch(search, page.getOffset(), page.getRows());
		int count =yhContactsMapper.countPageBySearch(search);
		page.setCount(count);
		page.setList(list);
		return page;
	}

}
